package com.example.wangzh.developkit.control;

import android.util.Log;
import android.view.View;

import com.example.wangzh.developkit.R;
import com.example.wangzh.developkit.base.BaseActivity;
import com.example.wangzh.developkit.utils.count_down_manager.CountDownManager;

import java.util.Date;

import butterknife.OnClick;

/**
 * Created by zhwang16 on 2017/12/13.
 */

public class CountDownManagerActivity extends BaseActivity {
    CountDownManager countDownManager;

    @Override
    protected int getLayout() {
        return R.layout.activity_count_down_manager;
    }

    @Override
    protected void initView() {
        countDownManager = new CountDownManager(5000, 5);
        countDownManager.setITime(new CountDownManager.ITime() {
            @Override
            public void onTick(long millisUntilFinished) {
                Log.i("time", "onNext>>>" + millisUntilFinished + ">>>" + new Date().toString());
            }

            @Override
            public void onFinish() {
                Log.i("time", "onStop>>>" + new Date().toString());
            }
        });
    }

    @OnClick({R.id.btn_start, R.id.btn_reset, R.id.btn_cancel})
    protected void click(View view) {
        switch (view.getId()) {
            case R.id.btn_start:
                countDownManager.start();
                break;
            case R.id.btn_reset:
                countDownManager.setPeriod(1000);
                countDownManager.setRepeatTimes(10);
                countDownManager.start();
                break;
            case R.id.btn_cancel:
                countDownManager.cancel();
                break;
            default:
                break;
        }
    }
}
